
import React from 'react'
import { connect } from 'dva-no-router'
import { bindActionCreators } from 'redux'

import UI from '../../components/login';
import {BackHandler, Platform, ToastAndroid,NativeModules,BackAndroid,} from "react-native";

class App extends React.Component {

  componentWillMount(){
    const {getApi} = this.props;
    getApi();
    if (Platform.OS === 'android') {
      BackHandler.addEventListener('hardwareBackPress', () => {
        return true
      })
    }
  }
  componentWillUnmount() {
    if (Platform.OS === 'android') {
      BackHandler.removeEventListener('hardwareBackPress',()=>{});
    }
  }

  render() {
    return (
      <UI {...this.props}/>
    )
  }
}

const actions = {
    change: (val) => ({type: 'login/change', payload:val}),
    login: () => ({type: 'login/login'}),
    thisCancled: () => ({type: 'login/thisCancled'}),
    getApi:(val) =>({type:'login/getApi',payload:val}),
    thisPressIn:() =>({type:'login/thisPressIn'}),
    thisPressOut:() =>({type:'login/thisPressOut'}),
    showThisView:(val) =>({type:'login/showThisView', payload:val}),
    showTheView:(val) =>({type:'login/showTheView', payload:val}),
};

const mapProps = ({login}) => ({...login});

const mapActions = dispatch => ({
  ...bindActionCreators({...actions}, dispatch)
});

export default connect(mapProps, mapActions)(App)